Web Application Development with MEAN by Amos Q. Haviv & Adrian Mejia & Robert Onodi

Web Application Development with MEAN by Amos Q. Haviv & Adrian Mejia & Robert Onodi

Author:Amos Q. Haviv & Adrian Mejia & Robert Onodi [Haviv, Amos Q.]
Language: eng
Format: azw3
Publisher: Packt Publishing
Published: 2016-10-28T04:00:00+00:00


Product model implementation

The following changes are needed to meet our (test) requirements:

/* server/api/product/product.model.js *excerpt */ var ProductSchema = new Schema({ title: { type: String, required: true, trim: true }, price: { type: Number, required: true, min: 0 }, stock: { type: Number, default: 1 }, description: String });

Now all the tests should succeed and will look similar to this:

Product ✓ should not create without title ✓ should remove trailing spaces from title ✓ should default stock to 1 ✓ should not create without price ✓ should not allow negative price ✓ should save a description



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.